<template>
  <el-row :gutter="20" class="data-overview">
    <el-col :span="6" v-for="(item, index) in cardData" :key="index">
      <el-card class="data-card">
        <div class="card-header">
          <span class="title">{{ item.title }}</span>
          <el-icon :size="20">
            <User v-if="item.icon === 'User'" />
            <Goods v-if="item.icon === 'Goods'" />
            <ShoppingCart v-if="item.icon === 'ShoppingCart'" />
            <Money v-if="item.icon === 'Money'" />
          </el-icon>
        </div>
        <div class="divider"></div>
        <div class="card-content">
          <div class="data-section">
            <span class="number">{{ item.value }}</span>
            <div class="trend">
              <span class="label">较上月</span>
              <span class="value">{{ item.trend }}</span>
            </div>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>

<script setup lang="ts">
import { User, Goods, ShoppingCart, Money } from '@element-plus/icons-vue'

const cardData = [
  {
    title: '用户总数',
    value: '1,234',
    trend: '+12%',
    icon: 'User'
  },
  {
    title: '商品价格',
    value: '5,678',
    trend: '+8%',
    icon: 'Goods'
  },
  {
    title: '订单总数',
    value: '3,456',
    trend: '+15%',
    icon: 'ShoppingCart'
  },
  {
    title: '图片生成总数',
    value: '89,123',
    trend: '+20%',
    icon: 'Money'
  }
]
</script>

<style scoped>
.data-overview {
  margin-bottom: 20px;
}

.data-card {
  height: 140px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 45px;
  padding: 0 15px;
}

.card-header .title {
  font-size: 14px;
  color: #606266;
}

.card-header .el-icon {
  color: #606266;
}

.divider {
  height: 1px;
  background-color: #ebeef5;
}

.card-content {
  height: calc(100% - 60px);
  padding: 20px 15px 15px;
}

.data-section {
  height: 100%;
  position: relative;
}

.number {
  font-size: 26px;
  font-weight: bold;
  background: linear-gradient(45deg, #ff69b4, #fad0c4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: absolute;
  left: 0;
  top: 30%;
  transform: translateY(-50%);
}

.trend {
  position: absolute;
  right: 0;
  bottom: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend .label {
  color: #909399;
}

.trend .value {
  color: #67c23a;
  background-color: rgba(103, 194, 58, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

:deep(.el-card__body) {
  padding: 0;
}

.el-col {
  padding: 10px;
}
</style>
